﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DIProject.Data
{
    public class Manufacturer
    {
        private static DataSets.Dictionary.ManufacturersDataTable _data;
        public static DataSets.Dictionary.ManufacturersDataTable Data
        {
            get
            {
                if (_data == null)
                {
                    try
                    {
                        DataSets.DictionaryTableAdapters.ManufacturersTableAdapter adapter = new DIProject.DataSets.DictionaryTableAdapters.ManufacturersTableAdapter();
                        _data = new DIProject.DataSets.Dictionary.ManufacturersDataTable();
                        //_data = adapter.GetData(DIProject.Data.Sync.IsAdmin);
                        adapter.Fill(_data, DIProject.Data.Sync.IsAdmin);
                    }
                    catch (Exception ee)
                    {
                        string s = ee.ToString();
                        throw ee;
                    }
                }
                return _data;
            }
        }
        private static void ClearData()
        {
            _data = null;
        }
    }
    public abstract class Test<T> where T:System.Data.DataTable
    {
        protected static T _data;
        public abstract T Data
        {
            get;                   
        }
        public void ClearData()
        {
            _data = null;
        }
    }
    public class Test2 : Test<DataSets.Dictionary.ManufacturersDataTable>
    {
        public override DIProject.DataSets.Dictionary.ManufacturersDataTable Data
        {
            get
            {
                if (_data == null)
                {
                    DataSets.DictionaryTableAdapters.ManufacturersTableAdapter adapter = new DIProject.DataSets.DictionaryTableAdapters.ManufacturersTableAdapter();
                    _data = adapter.GetData(DIProject.Data.Sync.IsAdmin);
                }
                return _data;
            }
        }
    }
}
